home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Video
/
World of Video.iso
/
gfxprograms
/
3dprograms
/
rayshade-4.0
/
rayfiles
/
rsdefs
/
objects
/
rounded.rh
< prev
next >
Wrap
Text File
|
1995-02-13
|
13KB
|
407 lines
/************************************************************************
*
* rounded.rh
*
* This is an #include file for the Rayshade Standard Header
* Files. It defines the "rounded" superprimitives in the package.
*
* Please do not edit this file, or any of the other files in
* this package! Make additions to these in your own separate
* file. If you think you have something that should be added
* permanently, please send it to Larry Coffin and/or David
* DeBry (email addresses listed below). If we include it in
* the next release, we'll put your name in the contributor's
* list.
*
* Contributors (in alphabetical order):
* Larry Coffin <lcoffin@clciris.chem.umr.edu>
* David DeBry <ddebry@dsd.es.com>
* Stuart Warmink <sw@groucho.att.com>
*/
#ifndef RSHF_ROUNDED
#define RSHF_ROUNDED
/*************************************************************************
*
* Box with rounded edges and corners. x1, y1, z1 and x2, y2, z2
* are the opposing corners of the box, the coordinates of the first
* corner must be less that the second corner (ie. x1 < x2, etc.)
* (the rounded box does not extend outside this defined box).
* r is the radius of the corners of the box.
*
*/
#define RSProundedbox(prefix,x1,y1,z1,x2,y2,z2,r) \
prefix union \
union \
union \
box (x1) ((y1)+(r)) ((z1)+(r)) (x2) ((y2)-(r)) ((z2)-(r)) \
box ((x1)+(r)) (y1) ((z1)+(r)) ((x2)-(r)) (y2) ((z2)-(r)) \
end \
box ((x1)+(r)) ((y1)+(r)) (z1) ((x2)-(r)) ((y2)-(r)) (z2) \
end \
union \
union \
union \
union \
sphere (r) ((x1)+(r)) ((y1)+(r)) ((z1)+(r)) \
list \
cylinder (r) ((x1)+(r)) ((y1)+(r)) ((z1)+(r)) \
((x2)-(r)) ((y1)+(r)) ((z1)+(r)) \
disc (r) ((x1)+(r)) ((y1)+(r)) ((z1)+(r)) -1 0 0\
disc (r) ((x2)-(r)) ((y1)+(r)) ((z1)+(r)) 1 0 0\
end \
end \
union \
sphere (r) ((x2)-(r)) ((y1)+(r)) ((z1)+(r)) \
list \
cylinder (r) ((x2)-(r)) ((y1)+(r)) ((z1)+(r)) \
((x2)-(r)) ((y2)-(r)) ((z1)+(r)) \
disc (r) ((x2)-(r)) ((y1)+(r)) ((z1)+(r)) 0 -1 0\
disc (r) ((x2)-(r)) ((y2)-(r)) ((z1)+(r)) 0 1 0\
end \
end \
end \
union \
union \
sphere (r) ((x2)-(r)) ((y2)-(r)) ((z1)+(r)) \
list \
cylinder (r) ((x2)-(r)) ((y2)-(r)) ((z1)+(r)) \
((x1)+(r)) ((y2)-(r)) ((z1)+(r)) \
disc (r) ((x2)-(r)) ((y2)-(r)) ((z1)+(r)) 1 0 0\
disc (r) ((x1)+(r)) ((y2)-(r)) ((z1)+(r)) -1 0 0\
end \
end \
union \
sphere (r) ((x1)+(r)) ((y2)-(r)) ((z1)+(r)) \
list \
cylinder (r) ((x1)+(r)) ((y2)-(r)) ((z1)+(r)) \
((x1)+(r)) ((y1)+(r)) ((z1)+(r)) \
disc (r) ((x1)+(r)) ((y2)-(r)) ((z1)+(r)) 0 1 0\
disc (r) ((x1)+(r)) ((y1)+(r)) ((z1)+(r)) 0 -1 0\
end \
end \
end \
end \
union \
union \
union \
list \
cylinder (r) ((x1)+(r)) ((y1)+(r)) ((z1)+(r)) \
((x1)+(r)) ((y1)+(r)) ((z2)-(r)) \
disc (r) ((x1)+(r)) ((y1)+(r)) ((z1)+(r)) 0 0 -1\
disc (r) ((x1)+(r)) ((y1)+(r)) ((z2)-(r)) 0 0 1\
end \
list \
cylinder (r) ((x2)-(r)) ((y1)+(r)) ((z1)+(r)) \
((x2)-(r)) ((y1)+(r)) ((z2)-(r)) \
disc (r) ((x2)-(r)) ((y1)+(r)) ((z1)+(r)) 0 0 -1\
disc (r) ((x2)-(r)) ((y1)+(r)) ((z2)-(r)) 0 0 1\
end \
end \
union \
list \
cylinder (r) ((x2)-(r)) ((y2)-(r)) ((z1)+(r)) \
((x2)-(r)) ((y2)-(r)) ((z2)-(r)) \
disc (r) ((x2)-(r)) ((y2)-(r)) ((z1)+(r)) 0 0 -1\
disc (r) ((x2)-(r)) ((y2)-(r)) ((z2)-(r)) 0 0 1\
end \
list \
cylinder (r) ((x1)+(r)) ((y2)-(r)) ((z1)+(r)) \
((x1)+(r)) ((y2)-(r)) ((z2)-(r)) \
disc (r) ((x1)+(r)) ((y2)-(r)) ((z1)+(r)) 0 0 -1\
disc (r) ((x1)+(r)) ((y2)-(r)) ((z2)-(r)) 0 0 1\
end \
end \
end \
union \
union \
union \
sphere (r) ((x1)+(r)) ((y1)+(r)) ((z2)-(r)) \
list \
cylinder (r) ((x1)+(r)) ((y1)+(r)) ((z2)-(r))\
((x2)-(r)) ((y1)+(r)) ((z2)-(r))\
disc (r) ((x1)+(r)) ((y1)+(r)) ((z2)-(r)) -1 0 0\
disc (r) ((x2)-(r)) ((y1)+(r)) ((z2)-(r)) 1 0 0\
end \
end \
union \
sphere (r) ((x2)-(r)) ((y1)+(r)) ((z2)-(r)) \
list \
cylinder (r) ((x2)-(r)) ((y1)+(r)) ((z2)-(r))\
((x2)-(r)) ((y2)-(r)) ((z2)-(r))\
disc (r) ((x2)-(r)) ((y1)+(r)) ((z2)-(r)) 0 -1 0\
disc (r) ((x2)-(r)) ((y2)-(r)) ((z2)-(r)) 0 1 0\
end \
end \
end \
union \
union \
sphere (r) ((x2)-(r)) ((y2)-(r)) ((z2)-(r)) \
list \
cylinder (r) ((x2)-(r)) ((y2)-(r)) ((z2)-(r))\
((x1)+(r)) ((y2)-(r)) ((z2)-(r)) \
disc (r) ((x2)-(r)) ((y2)-(r)) ((z2)-(r)) 1 0 0\
disc (r) ((x1)+(r)) ((y2)-(r)) ((z2)-(r)) -1 0 0\
end \
end \
union \
sphere (r) ((x1)+(r)) ((y2)-(r)) ((z2)-(r)) \
list \
cylinder (r) ((x1)+(r)) ((y2)-(r)) ((z2)-(r))\
((x1)+(r)) ((y1)+(r)) ((z2)-(r))\
disc (r) ((x1)+(r)) ((y2)-(r)) ((z2)-(r)) 0 1 0\
disc (r) ((x1)+(r)) ((y1)+(r)) ((z2)-(r)) 0 -1 0\
end \
end \
end \
end \
end \
end \
end
/*************************************************************************
*
* A box frame made up of cylinder for the edges with spheres
* at the corners. x1,y1,z1 and x2,y2,z2 are the two opposite box
* corners (x1 < x2, etc) and r is the radius of the cylinders/spheres.
* The centers of the cylinders and spheres are aligned on the defined
* box. (Bounding box is larger than defined box by r on all sides.)
*
*/
#define RSPboxframe(prefix,x1,y1,z1,x2,y2,z2,r) \
prefix \
union \
union \
union \
union \
sphere (r) (x1) (y1) (z1) \
list \
cylinder (r) (x1) (y1) (z1) \
(x2) (y1) (z1) \
disc (r) (x1) (y1) (z1) -1 0 0 \
disc (r) (x2) (y1) (z1) 1 0 0 \
end \
end \
union \
sphere (r) (x2) (y1) (z1) \
list \
cylinder (r) (x2) (y1) (z1) \
(x2) (y2) (z1) \
disc (r) (x2) (y1) (z1) 0 -1 0 \
disc (r) (x2) (y2) (z1) 0 1 0 \
end \
end \
end \
union \
union \
sphere (r) (x2) (y2) (z1) \
list \
cylinder (r) (x2) (y2) (z1) \
(x1) (y2) (z1) \
disc (r) (x2) (y2) (z1) 1 0 0 \
disc (r) (x1) (y2) (z1) -1 0 0 \
end \
end \
union \
sphere (r) (x1) (y2) (z1) \
list \
cylinder (r) (x1) (y2) (z1) \
(x1) (y1) (z1) \
disc (r) (x1) (y2) (z1) 0 1 0 \
disc (r) (x1) (y1) (z1) 0 -1 0 \
end \
end \
end \
end \
union \
union \
union \
list \
cylinder (r) (x1) (y1) (z1) \
(x1) (y1) (z2) \
disc (r) (x1) (y1) (z1) 0 0 -1 \
disc (r) (x1) (y1) (z2) 0 0 1 \
end \
list \
cylinder (r) (x2) (y1) (z1) \
(x2) (y1) (z2) \
disc (r) (x2) (y1) (z1) 0 0 -1 \
disc (r) (x2) (y1) (z2) 0 0 1 \
end \
end \
union \
list \
cylinder (r) (x2) (y2) (z1) \
(x2) (y2) (z2) \
disc (r) (x2) (y2) (z1) 0 0 -1 \
disc (r) (x2) (y2) (z2) 0 0 1 \
end \
list \
cylinder (r) (x1) (y2) (z1) \
(x1) (y2) (z2) \
disc (r) (x1) (y2) (z1) 0 0 -1 \
disc (r) (x1) (y2) (z2) 0 0 1 \
end \
end \
end \
union \
union \
union \
sphere (r) (x1) (y1) (z2) \
list \
cylinder (r) (x1) (y1) (z2) \
(x2) (y1) (z2) \
disc (r) (x1) (y1) (z2) -1 0 0 \
disc (r) (x2) (y1) (z2) 1 0 0 \
end \
end \
union \
sphere (r) (x2) (y1) (z2) \
list \
cylinder (r) (x2) (y1) (z2) \
(x2) (y2) (z2) \
disc (r) (x2) (y1) (z2) 0 -1 0 \
disc (r) (x2) (y2) (z2) 0 1 0 \
end \
end \
end \
union \
union \
sphere (r) (x2) (y2) (z2) \
list \
cylinder (r) (x2) (y2) (z2) \
(x1) (y2) (z2) \
disc (r) (x2) (y2) (z2) 1 0 0 \
disc (r) (x1) (y2) (z2) -1 0 0 \
end \
end \
union \
sphere (r) (x1) (y2) (z2) \
list \
cylinder (r) (x1) (y2) (z2) \
(x1) (y1) (z2) \
disc (r) (x1) (y2) (z2) 0 1 0 \
disc (r) (x1) (y1) (z2) 0 -1 0 \
end \
end \
end \
end \
end \
end \
/*************************************************************************
*
* A cylinder with rounded corners. r1 is the radius of the
* cylinder, x1,y1,z1 and x2,y2,z2 are the two ends of the cylinder,
* and r2 is the radius of the rounded edges. (This object is bounded
* by the normal cylinder defined by r1 x1,y1,z1 and x2,y2,z2).
*
*/
#define RSPv0001_len(x1,y1,z1,x2,y2,z2) \
(sqrt(((x2)-(x1))^2+((y2)-(y1))^2+((z2)-(z1))^2))
#define RSPv0001_xp(x1,y1,z1,x2,y2,z2,r2) \
(((x2)-(x1))*(r2)/ RSPv0001_len(x1,y1,z1,x2,y2,z2))
#define RSPv0001_yp(x1,y1,z1,x2,y2,z2,r2) \
(((y2)-(y1))*(r2)/ RSPv0001_len(x1,y1,z1,x2,y2,z2))
#define RSPv0001_zp(x1,y1,z1,x2,y2,z2,r2) \
(((z2)-(z1))*(r2)/ RSPv0001_len(x1,y1,z1,x2,y2,z2))
#define RSProundedcylinder(prefix,r1,x1,y1,z1,x2,y2,z2,r2) \
prefix union \
union \
union \
list \
cylinder (r1) \
((x1)+RSPv0001_xp(x1,y1,z1,x2,y2,z2,r2)) \
((y1)+RSPv0001_yp(x1,y1,z1,x2,y2,z2,r2)) \
((z1)+RSPv0001_zp(x1,y1,z1,x2,y2,z2,r2)) \
((x2)-RSPv0001_xp(x1,y1,z1,x2,y2,z2,r2)) \
((y2)-RSPv0001_yp(x1,y1,z1,x2,y2,z2,r2)) \
((z2)-RSPv0001_zp(x1,y1,z1,x2,y2,z2,r2)) \
disc (r1) \
((x1)+RSPv0001_xp(x1,y1,z1,x2,y2,z2,r2)) \
((y1)+RSPv0001_yp(x1,y1,z1,x2,y2,z2,r2)) \
((z1)+RSPv0001_zp(x1,y1,z1,x2,y2,z2,r2)) \
(-RSPv0001_xp(x1,y1,z1,x2,y2,z2,r2)) \
(-RSPv0001_yp(x1,y1,z1,x2,y2,z2,r2)) \
(-RSPv0001_zp(x1,y1,z1,x2,y2,z2,r2)) \
disc (r1) \
((x2)-RSPv0001_xp(x1,y1,z1,x2,y2,z2,r2)) \
((y2)-RSPv0001_yp(x1,y1,z1,x2,y2,z2,r2)) \
((z2)-RSPv0001_zp(x1,y1,z1,x2,y2,z2,r2)) \
(RSPv0001_xp(x1,y1,z1,x2,y2,z2,r2)) \
(RSPv0001_yp(x1,y1,z1,x2,y2,z2,r2)) \
(RSPv0001_zp(x1,y1,z1,x2,y2,z2,r2)) \
end \
list \
cylinder ((r1)-(r2)) (x1) (y1) (z1) (x2) (y2) (z2) \
disc ((r1)-(r2)) (x1) (y1) (z1) \
(-RSPv0001_xp(x1,y1,z1,x2,y2,z2,r2)) \
(-RSPv0001_yp(x1,y1,z1,x2,y2,z2,r2)) \
(-RSPv0001_zp(x1,y1,z1,x2,y2,z2,r2)) \
disc ((r1)-(r2)) (x2) (y2) (z2) \
(RSPv0001_xp(x1,y1,z1,x2,y2,z2,r2)) \
(RSPv0001_yp(x1,y1,z1,x2,y2,z2,r2)) \
(RSPv0001_zp(x1,y1,z1,x2,y2,z2,r2)) \
end \
end \
torus ((r1)-(r2)) (r2) \
((x1)+RSPv0001_xp(x1,y1,z1,x2,y2,z2,r2)) \
((y1)+RSPv0001_yp(x1,y1,z1,x2,y2,z2,r2)) \
((z1)+RSPv0001_zp(x1,y1,z1,x2,y2,z2,r2)) \
(-RSPv0001_xp(x1,y1,z1,x2,y2,z2,r2)) \
(-RSPv0001_yp(x1,y1,z1,x2,y2,z2,r2)) \
(-RSPv0001_zp(x1,y1,z1,x2,y2,z2,r2)) \
end \
torus ((r1)-(r2)) (r2) \
((x2)-RSPv0001_xp(x1,y1,z1,x2,y2,z2,r2)) \
((y2)-RSPv0001_yp(x1,y1,z1,x2,y2,z2,r2)) \
((z2)-RSPv0001_zp(x1,y1,z1,x2,y2,z2,r2)) \
(RSPv0001_xp(x1,y1,z1,x2,y2,z2,r2)) \
(RSPv0001_yp(x1,y1,z1,x2,y2,z2,r2)) \
(RSPv0001_zp(x1,y1,z1,x2,y2,z2,r2)) \
end
/*************************************************************************
*
* A disc with rounded edges. r is the radius of the
* disc, xp,yp,zp is the center of the disc, xn,yn,zn is the normal
* for the disc.
*
*/
#define RSPv0002_len(xn,yn,zn) (sqrt((xn)^2 + (yn)^2 + (zn)^2))
#define RSProundeddisc(prefix,r,xp,yp,zp,xn,yn,zn,t) \
prefix union \
list \
cylinder ((r)-(t/2)) \
((xp)+(t/2)*(xn)/ RSPv0002_len(xn,yn,zn)) \
((yp)+(t/2)*(yn)/ RSPv0002_len(xn,yn,zn)) \
((zp)+(t/2)*(zn)/ RSPv0002_len(xn,yn,zn)) \
((xp)-(t/2)*(xn)/ RSPv0002_len(xn,yn,zn)) \
((yp)-(t/2)*(yn)/ RSPv0002_len(xn,yn,zn)) \
((zp)-(t/2)*(zn)/ RSPv0002_len(xn,yn,zn)) \
disc ((r)-(t/2)) \
((xp)+(t/2)*(xn)/ RSPv0002_len(xn,yn,zn)) \
((yp)+(t/2)*(yn)/ RSPv0002_len(xn,yn,zn)) \
((zp)+(t/2)*(zn)/ RSPv0002_len(xn,yn,zn)) \
(xn) (yn) (zn) \
disc ((r)-(t/2)) \
((xp)-(t/2)*(xn)/ RSPv0002_len(xn,yn,zn)) \
((yp)-(t/2)*(yn)/ RSPv0002_len(xn,yn,zn)) \
((zp)-(t/2)*(zn)/ RSPv0002_len(xn,yn,zn)) \
(-xn) (-yn) (-zn) \
end \
torus ((r)-(t/2)) (t/2) (xp) (yp) (zp) (xn) (yn) (zn) \
end
#endif /* ifndef RSHF_ROUNDED */